app.controller('loujianshenqingPageCtrl',['$scope','$http','mainService','$location',function ($scope,$http,mainService,$location) {

    $scope.fzrtz = function ($event) {
        mainService.setFzrtz($event);
        $location.path('/renyuanxuanze')
    }
$scope.shenpiren = mainService.getFzr().staffName;
    console.log(mainService.getFzr());

    $scope.onChange = function () {

        mainService.setArr({
            loujianyuanyin:$scope.loujianyuanyin
        });
        console.log(mainService.getArr())
    }
    if(mainService.getArr()[0]) {
        if (mainService.getArr()[0].loujianyuanyin) {
            $scope.loujianyuanyin = mainService.getArr()[0].loujianyuanyin;
        }
        mainService.clearArr();
    }




    $scope.submit = function () {
        if(getInputs()==false){
            return;
        }
        var ljsq = mainService.getLjsq();
        console.log(ljsq);
        var jsonStr = [];
        for (var d = 0; d < ljsq.length; d++) {
            var jsonStrs;
            jsonStrs = {
                "tciSid": ljsq[d].sid,
                "checkPersonId": JSON.parse(localStorage.getItem('userData')).pin,
                "checkPerson": JSON.parse(localStorage.getItem('userData')).userNameCn,
                "approvedBy": mainService.getFzr().identityId,
                "approvedName": $scope.shenpiren,
                "uncheckedReason": $scope.loujianyuanyin,
                "version": ljsq[d].version
            };
            jsonStr.push(jsonStrs)
        }
        mui.showLoading('加载中...', 'div');
        var token = localStorage.getItem('token');
        $http({
            method: "POST",
            url: mainUrl + '/tr/tr-un-confirm!updateActual4App.action',
            params: {
                'Authorization': token,
                'qm.jsonStr': jsonStrs
            }
        }).then(
            function (data, status, headers, config) {
                console.log(data);
                //$scope.data = data.data.items;

                mui.hideLoading();
                mui.toast('提交成功');
                mainService.reset();
                $location.path('/loujiandaishenqing')
                // document.getElementsByClassName('mui-switch-blue').addEventListener
            }, function (data, status, headers, config) {
                console.log(data)
                mui.toast(data)
                console.log(status)
            })


    }
}]);